def findMax(matrix):
    if not matrix or not matrix[0]:
        return None
    max_val = max(max(row) for row in matrix)
    positions = []
    for i in range(len(matrix)):
        for j in range(len(matrix[0])):
            if matrix[i][j] == max_val:
                positions.append((i, j))
    positions.sort(key=lambda x: (x[0], x[1]))
    return (max_val, tuple(positions))

# === DO NOT modify the code below === 
def main():
    n = eval(input())
    matrix = []
    for i in range(n):
        row = [ eval(x) for x in input().split() ]
        matrix.append(row)
    max_value, max_indexes = findMax(matrix)
    print(max_value)
    for item in max_indexes:
        print(item[0],item[1],sep=',')
    
if __name__ == "__main__":
    main()
# === DO NOT modify the code above ===